package com.easy.component.ibase;

import android.app.Activity;
import android.app.Application;
import android.os.Bundle;

import java.util.ArrayList;
import java.util.List;

/**
 * 描述: {描述}
 * 作者:jack-song
 * 创建日期: 2017/11/2 10:26
 * 修改日期: 2017/11/2
 * 版本: {版本}
 */
public class EasyActivityLifecycleCallbacks implements Application.ActivityLifecycleCallbacks {
    private List<Activity> mActivityList = new ArrayList();
    private static final EasyActivityLifecycleCallbacks ourInstance = new EasyActivityLifecycleCallbacks();

    public static EasyActivityLifecycleCallbacks getInstance() {
        return ourInstance;
    }

    private EasyActivityLifecycleCallbacks() {
    }

    @Override
    public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
        if(!this.mActivityList.contains(activity)) {
            this.mActivityList.add(activity);
        }

    }

    @Override
    public void onActivityStarted(Activity activity) {
    }

    @Override
    public void onActivityResumed(Activity activity) {
    }

    @Override
    public void onActivityPaused(Activity activity) {
    }

    @Override
    public void onActivityStopped(Activity activity) {
    }

    @Override
    public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
    }

    @Override
    public void onActivityDestroyed(Activity activity) {
        if(this.mActivityList.contains(activity)) {
            this.mActivityList.remove(activity);
        }

    }

    public List<Activity> getActivityList() {
        return this.mActivityList;
    }
}
